package com.example.xinwenkehuduan;

import android.os.Bundle;
import android.widget.ListView;

import androidx.appcompat.app.AppCompatActivity;

import com.example.xinwenkehuduan.Adapter.MyNewsAdapter;

import java.util.ArrayList;
import java.util.List;

public class SecondActivity extends AppCompatActivity {

    private ListView listview;
    private List<MyTestBean>list;
    private MyTestBean bean;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_second);
        initView();
    }

    private void initView() {
        listview = (ListView) findViewById(R.id.listview);
        list=new ArrayList<>();
        for (int i = 0; i < 40; i++) {
            if (i%2==0){
                bean = new MyTestBean("莫让网课变“网游” 最高法：未成年人网游充值可退还"+i,"2020-06-09 10:06"+i,"张三"+i,R.mipmap.ic_launcher);
                bean.setType(0);
            }else {
                bean = new MyTestBean("“三K党”出现了！美国男子驾车冲进示威人群后被捕，检方称其为该组织“公认头目","2020-06-09 09:31","环球网",R.mipmap.ic_launcher,R.mipmap.ic_launcher,R.mipmap.ic_launcher);
                bean.setType(1);
            }
            list.add(bean);
        }
        listview.setAdapter(new MyNewsAdapter(list,this));
    }
}
